﻿using UnityEngine;
using System.Collections;

public class Badge : MonoBehaviour
{
	public UILabel countLabel;

	int m_badgeCount;
	public int badgeCount
	{
		get { return m_badgeCount; }
		set
		{
			m_badgeCount = value;
			UpdateBadgeCount();
		}
	}

	void Awake()
	{
		SetActive(false);
	}

	void UpdateBadgeCount()
	{
		Debug.Log ("UpdateBadgeCount");

		if (countLabel == null)
			return;

		if (m_badgeCount > 0)
		{
			countLabel.text = m_badgeCount.ToString();
			SetActive(true);
		}
		else
		{
			SetActive(false);
		}

	}

	public void SetActive(bool isActive)
	{
		NGUITools.SetActive(this.gameObject, isActive);
	}
}
